<!--
 * @Author: weidewei
 * @Date: 2025-10-29 09:45:42
 * @LastEditors: weidewei
 * @LastEditTime: 2025-10-29 10:14:06
 * @Description: 
 * @FilePath: \2025-front-face\review-knowledge\20251028\复习手写new操作符.html
-->
<script>
    function test(name,age) {
       this.name = name;
       this.age = age;
       return {
        name: 'xx',
        age: 22
       }
    }

    function myNew(constructorFn,...args) {
       let obj = Object.create(constructorFn.prototype);
       let res = constructorFn.apply(obj,args);
       return typeof res === 'object' ? res : obj;  
    }

    const newT =  myNew(test,'张三',20)
    console.log(newT);
</script>